package com.css.listener.interfaces.impl;

import com.css.Main;
import com.css.entity.CustomShortcutKeyKey;
import com.css.entity.CustomShortcutKeyName;
import com.css.entity.KeyMapWrapper;
import com.css.entity.NeedUploadMap;
import com.css.listener.MyKeyCode;
import com.css.listener.interfaces.KeyBorderListener;

import java.util.List;

/**
 * <p>
 * -
 * </p>
 *
 * @author css
 * @since 2019/1/10
 */
public class KeyBorderListenerAdapter implements KeyBorderListener {
    @Override
    public void onDown(int keyCode) {
        //css//用户还没加载出来，
        if (Main.getUser() == null) {
            return;
        }
//        System.out.println(KeyMapWrapper.getKeys());
        List<CustomShortcutKeyName> customShortcutKeyNameList = Main.getUser().getCustomShortcutKeyNameList();
        for (CustomShortcutKeyName customShortcutKeyName : customShortcutKeyNameList) {
            boolean isFind = true;
            for (CustomShortcutKeyKey customShortcutKeyKey : customShortcutKeyName.getCustomShortcutKeyKeyList()) {
                if (!KeyMapWrapper.getKeys().contains(customShortcutKeyKey.getVkCode())) {
                    isFind = false;
                    break;
                }
            }
            if(isFind){
                System.out.println(customShortcutKeyName.getKeyName());
            }
        }
//        if (KeyMapWrapper.size() > 1 && (KeyMapWrapper.isHas(MyKeyCode.CONTROL.getVkCode()) || KeyMapWrapper.isHas(MyKeyCode.ALT.getVkCode()))) {
//            //按下不止一个键
//            System.out.println("组合键");
//            if (KeyMapWrapper.size() == 2) {//大小为2的组合键
//                if (KeyMapWrapper.isHas(MyKeyCode.CONTROL.getVkCode())) {
//                    switch (keyCode) {
//                        case MyKeyCode.C.vkCode:
//                            NeedUploadMap.addNum("复制");
//                            break;
//                        case MyKeyCode.V.getVkCode():
//                            NeedUploadMap.addNum("粘贴");
//                            break;
//                        case MyKeyCode.S:
//                            NeedUploadMap.addNum("保存");
//                            break;
//                        case MyKeyCode.D:
//                            NeedUploadMap.addNum("删除");
//                            break;
//                        case MyKeyCode.F:
//                            NeedUploadMap.addNum("搜索");
//                            break;
//                        case MyKeyCode.A:
//                            NeedUploadMap.addNum("全选");
//                            break;
//                        case MyKeyCode.Z:
//                            NeedUploadMap.addNum("撤销");
//                            break;
//                        case MyKeyCode.X:
//                            NeedUploadMap.addNum("剪切");
//                            break;
//                    }
//                } else if (KeyMapWrapper.isHas(MyKeyCode.ALT.getVkCode())) {
//                    switch (keyCode) {
//                        case MyKeyCode.TAB:
//                            NeedUploadMap.addNum("切换窗口");
//                            break;
//                    }
//                }
//            } else {
//                //大小大于2的组合键
//                if (keyCode == MyKeyCode.A.getVkCode() && KeyMapWrapper.isHas(MyKeyCode.ALT.getVkCode(), MyKeyCode.CONTROL.getVkCode())) {
//                    NeedUploadMap.addNum("qq截图");
//                } else if (keyCode == MyKeyCode.F.getVkCode() && KeyMapWrapper.isHas(MyKeyCode.SHIFT.getVkCode(), MyKeyCode.CONTROL.getVkCode())) {
//                    NeedUploadMap.addNum("代码格式化(ctrl+shift+f)");
//                }
//            }
//        } else {
        // System.out.println("打字");
//        }
    }

    @Override
    public void onUp(int keyCode) {
        KeyMapWrapper.remove(keyCode);
    }

    @Override
    public void onPress(int keyCode) {

    }

}
